<?php

require_once 'Dsql.php';
$db = new Dsql("mysql-88.ukraine.com.ua", "barthez_ai", "x9gedv4w");


$db->selectDb('barthez_ai');
$db->selectCharset('utf8');

$aphorism = $db->createQuery("SELECT * FROM `byone` where aphorismId={$_GET['id']}")
        ->setLimit(0, 1)
        ->getResult();
$aphorism = $aphorism[0];

$aphorisms = $db->createQuery("SELECT * FROM `byone` where CHAR_LENGTH(`text`) < 60 order by rand()")
                ->setLimit(0, 39)
                ->getResult();



?>
<html>
    <head>
        <script type="text/javascript">

                    var _gaq = _gaq || [];
                    _gaq.push(['_setAccount', 'UA-19921719-1']);
                    _gaq.push(['_trackPageview']);

                    (function() {
                        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
                        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
                    })();

                </script>
        <title>Афоризмы в картинках - <?= $aphorism['theme']?></title>
        <meta name="description" content="Автор: <?=$aphorism['theme']?> . Картинка: <?=$aphorism['text']?> (<?=$aphorism['aphorismId']?>)"/>
        <meta name="robots" content="INDEX, FOLLOW" />
        <link type="text/css" rel="stylesheet" media="screen" href="minniFw.css" />
    </head>
    <body>
        <div class="w-1000 margin-auto">
            <div class="valign-top w-350 margin-auto">
                <? for ($i = 1; $i <= 1; $i++): ?>
                    <img src="./appBox/img-<?= $_GET['id'] ?><?= $i ?>.png?text=<?= $aphorism['theme'] ?>: <?= $aphorism['text'] ?>&backId=<?= $i ?>" alt="<?= $aphorism['text'] ?>" title="Картинка для: <?= $aphorism['aphorismId'] ?> <?= $aphorism['text'] ?>"/>
                <? endfor; ?>
            </div>
            
            <hr />
            <div class="valign-top">
                
                    <? foreach($aphorisms as $one):?>
                        <a href="./apho-<?=$one['aphorismId']?>.html" title="перейти к">
                            <img class="pm-2" src="./appBox/img-<?=$one['aphorismId']?>.png?text=<?=$one['text']?>" alt="<?= $aphorism['text'] ?>" title="Картинка для: <?= $one['aphorismId'] ?> <?= $one['text'] ?>"/></a>
                   
                   <? endforeach;?>
                
                   
            </div>

        </div>    
    
    
    </body>
    
    
</html>